package com.library.controller;

import com.library.service.LoginService;
import com.library.vo.BaseResult;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class GlobalExceptionHandler {

    private final static Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    // 处理特定异常
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public BaseResult handleException(Exception e) {
        log.error(e.getMessage(),e);
        return BaseResult.fail(e.getMessage());
    }

    // 处理特定异常
    @ExceptionHandler(RCException.class)
    @ResponseBody
    public BaseResult handleException(RCException e) {
        log.error(e.getMessage(),e);
        return BaseResult.fail(e.getMessage());
    }

}
